package test01;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-04-01
 * Time: 19:36
 */
public class Demo01 {
    public static void main(String[] args) {
        int a = 10;
        int b = 0;

       try {  //try监控区域
            System.out.println( a/b );
        } catch (Exception e) {  // catch 想要捕获的异常类型
            System.out.println("Error");
        } finally { //处理善后工作，也可以不要  通常在finally中处理IO、资源及关闭等操作，此处一定会执行
            System.out.println("finally");
        }

        //可以使用Ctrl + Alt + t 快速生成 try catch finally语句,选中要监控的语句，按下快捷键，选择try catch finally
        try {
            System.out.println( a/b );
        } catch (Error m ) {
            System.out.println("Exception");
        } catch (Exception t) {
            System.out.println("Error");
        } catch (Throwable n) {
            System.out.println("Throwable");
        }
        finally {
            System.out.println("finally");
        }
    }
}
